<?php
error_reporting(0);
include("filter.php");
header('Content-type:text/json;charset=utf-8');     //这句是重点，它告诉接收数据的对象此页面输出的是json数据；
echo "&";
$mysqli = new mysqli('localhost', 'GameServer', 'J8TED4Ks3CPkAdHY', 'gameserver');

$from = $_GET['from'];
$to = $_GET['to'];

$from = filter($from);
$to = filter($to);

if ($mysqli->connect_error) {
    die('{"Connect Error (' . $mysqli->connect_errno . ')&' . $mysqli->connect_error);
}
if((empty($from) && !empty($to)) || (!empty($from) && empty($to))){
    die('Need More Information&');
}
if($from > $to){
    die('Input Error!&');
}

if(empty($from) && empty($to)){
    $sql = "SELECT * FROM `data` ORDER BY `data`.`level` DESC limit 10";
} else {
    $sql = "SELECT * FROM `data` ORDER BY `data`.`level` DESC, `data`.`lastTime` ASC limit ". $from - 1 . "," . $to;
}

$result = $mysqli->query($sql);
if (mysqli_num_rows($result) > 0) {
    // 输出数据
    while($row = mysqli_fetch_assoc($result)) {
        echo $row['id']." ".$row['totilKilled']." ".$row['maxOnceKilled']." ".$row['level']." ".$row['lastTime']." ".$row['updatetime']." ";
    }
} else {
}
 

echo $arr;
echo "&";
?>